import { http } from "@/utils/http";
import type { HttpResult } from "@/utils/http/types";

// 任务完成审批
export function complete(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/complete", {
    data: obj
  });
}

// 退回首节点
export function backFirstJob(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/backfirst", {
    data: obj
  });
}

// 退回上一步
export function backPreJob(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/backpre", {
    data: obj
  });
}

// 任意跳转
export function anyJump(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/anyjump", {
    data: obj
  });
}

// 任意驳回
export function reject(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/reject", {
    data: obj
  });
}

// 加签
export function signature(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/signon", {
    data: obj
  });
}

// 减签
export function signoff(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/signoff", {
    data: obj
  });
}

// 任务挂起/激活
export function suspension(obj: object) {
  return http.request<HttpResult>("put", "/esflow/task/suspension", {
    data: obj
  });
}

// 任务签收/反签收
export function signForJob(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/sign", {
    data: obj
  });
}

// 处理转办逻辑
export function turnRunJob(obj: object) {
  return http.request<HttpResult>("put", "/esflow/task/turn", {
    data: obj
  });
}

// 处理转办逻辑
export function retake(obj: object) {
  return http.request<HttpResult>("post", "/esflow/task/retake", {
    data: obj
  });
}

export function remind(obj: object) {
  return http.request<HttpResult>("put", "/esflow/task/remind", {
    data: obj
  });
}

// 指定人员
export function appointUser(obj: object) {
  return http.request<HttpResult>("put", "/esflow/task/appoint", {
    data: obj
  });
}

// 指定下一任务人员
export function appointNextUser(obj: object) {
  return http.request<HttpResult>("put", "/esflow/task/appoint/next", {
    data: obj
  });
}

// 获取待办任务
export function fetchTodoPage(query: object) {
  return http.request<HttpResult>("get", "/esflow/task/todo/page", {
    params: query
  });
}

// 获取待办任务数量
export function fetchTodoSize(query: object) {
  return http.request<HttpResult>("get", "/esflow/task/todo/size", {
    params: query
  });
}

// 审批前获取节点配置信息
export function getTodoDetail(query: object) {
  return http.request<HttpResult>("get", "/esflow/task/todo/detail", {
    params: query
  });
}

export function getProgress(flowInstId: string) {
  return http.request<HttpResult>(
    "get",
    `/esflow/task/get/progress/${flowInstId}`
  );
}

// 是否已阅
export function isRead(obj: object) {
  return http.request<HttpResult>("put", "/esflow/task/isread", {
    data: obj
  });
}
